<?php
my_component_load('testing' , false);
my_component_load('paging' , false); 
my_component_load('data_setting', false);
my_component_load('kompetensi' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$kid = isset( $_GET['kid'] ) ? $_GET['kid']:  0;
$uid = isset( $_GET['uid'] ) ? $_GET['uid']:  0;
$pid = isset( $_GET['pid'] ) ? $_GET['pid']:  0;
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$modulname = "Admin _BN_ Konfigurasi Data";

if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case   "kompetensi_kelompok_page" :
			$validatepost = form_kompetensi_kelompok_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_kompetensi_kelompok_create($id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_kompetensi_kelompok_submit($id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=kompetensi_kelompok');
			break;
		case   "kompetensi_unit_page" :
			$validatepost = form_kompetensi_unit_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_kompetensi_unit_create($kid,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_kompetensi_unit_submit($kid,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=kompetensi&task=list_kompetensi_unit&kid='.$kid);
			break;			
		case   "kompetensi_page" :
			$validatepost = form_kompetensi_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_kompetensi_create($uid,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_kompetensi_submit($uid,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=kompetensi&task=list_kompetensi&uid='.$uid);
			break;	
		case   "kompetensi_indikator_page" :
			$validatepost = form_kompetensi_indikator_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_kompetensi_indikator_create($uid,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_kompetensi_indikator_submit($pid,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=kompetensi&task=list_kompetensi_indikator&pid='.$pid);
			break;				
		case "unit_kompetensi":
			form_unit_kategori_kompetensi_submit($kid,$id);
			$content =  "Updated";
			generate_my_web($content,"","plain.php");
			exit;
			break;
		case   "edit_kategori_kompetensi_page" :
			form_kategori_kompetensi_submit($id);
			$content =  "Updated";
			generate_my_web($content,"","plain.php");
			exit;
			break;
	}
else: 
	if($task == "kompetensi_kelompok_page"){ 
		$content  = form_kompetensi_kelompok_create($id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "kompetensi_kelompok_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data Kelompok Kompetensi" : "Tambah Data Kelompok Kompetensi";
		facebox_page('index.php?com=kompetensi&task=kompetensi_kelompok_page&id='.$id , $title , 200	);
	}elseif($task =='kompetensi_kelompok_delete'){
		 delete_kompetensi_kelompok($id);
		 my_direct($_SERVER['HTTP_REFERER']);	
	}elseif($task =='list_kompetensi_unit'){	
		$pagename = "Unit kompetensi";
		load_facebox_script();
		$view =  list_kompetensi_unit($kid); 
		$href = 'index.php?com=kompetensi&task=kompetensi_unit_create&kid='.$kid.'&id=0';
	}elseif($task == "kompetensi_unit_page"){ 
		$content  = form_kompetensi_unit_create($kid,$id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "kompetensi_unit_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data unit Kompetensi" : "Tambah Data unit Kompetensi";
		facebox_page('index.php?com=kompetensi&task=kompetensi_unit_page&kid='.$kid.'&id='.$id , $title , 200	);
	}elseif($task =='kompetensi_unit_delete'){
		 delete_kompetensi_unit($id);
		 my_direct($_SERVER['HTTP_REFERER']);	
	}elseif($task =='list_kompetensi'){		 
		$pagename = "Daftar Kompetensi";
		load_facebox_script();
		$view =  list_kompetensi($uid); 
		$href = 'index.php?com=kompetensi&task=kompetensi_create&uid='.$uid.'&id='.$id;
	}elseif($task == "kompetensi_page"){ 
		$content  = form_kompetensi_create($uid,$id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "kompetensi_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data Kompetensi" : "Tambah Data Kompetensi";
		facebox_page('index.php?com=kompetensi&task=kompetensi_page&uid='.$uid.'&id='.$id , $title , 340	);
	}elseif($task =='kompetensi_delete'){
		 delete_kompetensi($id);
		 my_direct($_SERVER['HTTP_REFERER']);		 
	}elseif($task =='list_kompetensi_indikator'){		 
		$pagename = "Daftar Indikator Kompetensi";
		load_facebox_script();
		$view =  list_kompetensi_indikator($pid);
		$href = 'index.php?com=kompetensi&task=kompetensi_indikator_create&pid='.$pid.'&id='.$id ; 
	}elseif($task == "kompetensi_indikator_page"){ 
		$content  = form_kompetensi_indikator_create($pid,$id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "kompetensi_indikator_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data Indikator Kompetensi" : "Tambah Data Indikator Kompetensi";
		facebox_page('index.php?com=kompetensi&task=kompetensi_indikator_page&pid='.$pid.'&id='.$id , $title , 200	);
	}elseif($task =='kompetensi_indikator_delete'){
		 delete_kompetensi_indikator($id);
		 my_direct($_SERVER['HTTP_REFERER']);			 

	}else{
		$pagename = "Kelompok kompetensi";
		load_facebox_script();
		$view =  list_kompetensi_kelompok(); 
		$href = 'index.php?com=kompetensi&task=kompetensi_kelompok_create';
	}
endif; 
$content = spliter_browser( $view , $pagename ,$href);
generate_my_web($content, $modulname." _BN_ Kompetensi" );

?>